//
//  WYStrictSeletedTableViewCell.m
//  Boss
//
//  Created by admin on 2018/9/10.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYStrictSeletedTableViewCell.h"
#import "WYHotIndustryCollectionViewCell.h"
#import "CJStrictSeletedCollectionViewCell.h"
#import "CJBOSSChannel.h"
@interface WYStrictSeletedTableViewCell()<UICollectionViewDelegate,UICollectionViewDataSource>

@property (nonatomic,strong) UICollectionView *collectionView;

@end
@implementation WYStrictSeletedTableViewCell

-(void)setDataArray:(NSMutableArray *)dataArray
{
    _dataArray = dataArray;
    [self.collectionView reloadData];
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createSubViews];
    }
    
    
    return self;
}

-(void)createSubViews
{
   
    
    UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc]init];
    layout.itemSize=CGSizeMake(kScreenWidth-75,(kScreenWidth-75)/300*173);
    //横向最小距离
    layout.minimumInteritemSpacing=10.0f;
    layout.minimumLineSpacing=10.0f;
    //cell距离上  左  下 右 的距离
    layout.sectionInset=UIEdgeInsetsMake(10, 16, 10, 10);
    [layout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
   // [self.collectionView setCollectionViewLayout:layout];
    
   
    
    self.collectionView = [[UICollectionView alloc]initWithFrame:self.bounds collectionViewLayout:layout];
    self.collectionView.backgroundColor = [UIColor whiteColor];
    [self.collectionView registerNib:[UINib nibWithNibName:@"CJStrictSeletedCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"CJStrictSeletedCollectionViewCell"];
    self.collectionView.dataSource=self;
    self.collectionView.delegate = self;
    
    [self addSubview:self.collectionView];
    [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.mas_equalTo(0);
        make.height.mas_equalTo(200);
    }];
    
    
    
    
    
   // self.collectionView.frame = self.bounds;
    
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.dataArray.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    CJStrictSeletedCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CJStrictSeletedCollectionViewCell" forIndexPath:indexPath];
    if (!cell) {
        cell = [[NSBundle mainBundle]loadNibNamed:@"CJStrictSeletedCollectionViewCell" owner:nil options:nil].firstObject;
    }
    
    CJBOSSChannel *channel = self.dataArray[indexPath.row];
   
    [cell setChannel:channel];
    //    WYBusinessType *businessType = self.dataArray[indexPath.row];
    //    [cell.typeImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@!default",businessType.url]] placeholderImage:[UIImage imageNamed:@"品牌专区_2"]];
    //    NSLog(@"%@",businessType.name);
    //  cell.typeLabel.text = businessType.name;
//    cell.typeImage.image = [UIImage imageNamed:self.imageArray[indexPath.row]];
//    cell.typeLabel.text = self.nameArray[indexPath.row];
    return cell;
}



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
